package com.example.controller;


import com.example.base.response.Result;
import com.example.entity.Nurse;
import com.example.entity.Params;
import com.example.service.NurseService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "宠物服务管理")
@CrossOrigin
@RestController
@RequestMapping("/nurse")
public class NurseController {
    @Autowired
    private NurseService nurseService;


    @GetMapping("/search")
    public Result findBySearch(Params params) {
        PageInfo<Nurse> info = nurseService.findBySearch(params);
        return Result.success(info);
    }

    @PostMapping
    public Result save(@RequestBody Nurse nurse) {
        if (nurse.getId() == null) {
            nurseService.add(nurse);
        } else {
            nurseService.update(nurse);
        }
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        nurseService.delete(id);
        return Result.success();
    }


}
